local yanzhu = fk.CreateSkill{
    name = "SP_heg__yanzhu",
}

Fk:loadTranslationTable{
    ["SP_heg__yanzhu"] = "宴诛",
    [":SP_heg__yanzhu"] = "出牌阶段限一次，你可以摸一张牌并将一张牌交给一名其他角色，然后对其发起<a href='heg_Command'>“军令”</a>，若其不执行，你弃置其两张牌。",
    ["#yanzhu-choose"] = "宴诛：选择一名其他角色",
    ["#SP_heg__yanzhu-active"] = "宴诛：是否发动",
    ["#yanzhu-chosencard"] = "宴诛：选择一张牌",
    ["#yanzhu-discards"]="宴诛：弃置两张手牌",
    ["#yanzhu-chosencards"] = "宴诛：选择两张手牌弃置",

    ["$SP_heg__yanzhu1"]="不诛此权臣，朕，何以治天下？",
    ["$SP_heg__yanzhu2"]="大局已定，你还是放弃吧！",
}

local H = require "packages.ol_hegemony.util"

yanzhu:addEffect("active",{
  anim_type = "defensive",
  target_num = 0,
  prompt = "#SP_heg__yanzhu-active",
  can_use = function(self, player)
    return player:usedSkillTimes(yanzhu.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    room:drawCards(player, 1, yanzhu.name)
    if player.dead then return end
    local to = room:askToChoosePlayers(player,{
        targets = table.filter(room:getOtherPlayers(player, false), function(p) return p ~= player end),
        min_num = 1,
        max_num = 1,
        prompt = "#yanzhu-choose",
        skill_name = yanzhu.name,
        cancelable = false,
    })
      if #to > 0 then
        local target = to[1]
        local id = room:askToChooseCard(player,{
            target = player,
            flag = "he",
            skill_name = yanzhu.name,
            prompt = "#yanzhu-chosencard",
        })
          room:obtainCard(target,{id},false,fk.ReasonGive)
         if  H.askCommandTo(player,target, yanzhu.name,false) then
          return true
         else
          if not target:isKongcheng() then
          local cards = room:askToChooseCards(player,{
            target = target,
            min = 1,
            max = 2,
            flag = "he",
            skill_name = yanzhu.name,
            prompt = "#yanzhu-discards",
          })
          if #cards > 0 then
            room:throwCard(cards, yanzhu.name, target, player)
          end
        end
      end
    end
  end,
})

return yanzhu